﻿namespace AgileBoard.Domain
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using Iesi.Collections.Generic;
    using SharpArch.Core.DomainModel;

    [Serializable]
    public class Status : Entity
    {
        private readonly ISet<Task> _tasks = new HashedSet<Task>();

        /// <summary>
        /// Created Date
        /// </summary>
        public virtual DateTime CreateTime { get; set; }

        /// <summary>
        /// Created by
        /// </summary>
        public virtual string Creator { get; set; }

        /// <summary>
        /// Iteration ID
        /// </summary>
        public virtual Guid StatusID { get; set; }

        /// <summary>
        /// Project ID
        /// </summary>
        public virtual string IterationID { get; set; }

        /// <summary>
        /// Iteration name
        /// </summary>
        public virtual string Name { get; set; }

        public virtual ReadOnlyCollection<Task> Tasks
        {
            get { return new List<Task>(_tasks).AsReadOnly(); }
        }

        public virtual void AddTask(Task task)
        {
            task.Status = this;
            _tasks.Add(task);
        }

        public virtual void RemoveTask(Task n)
        {
            _tasks.Remove(n);
        }
    }
}